#include "strDup.hh"

char *strDup(const char *str)
{
    if (NULL == str)
    {
        return NULL;
    }

    size_t len = strlen(str) + 1;
    char *copy = new char[len];
    memcpy(copy, str, len);
    
    return copy;
}

char *strDupSize(const char *str)
{
    if (NULL == str)
    {
        return NULL;
    }

    size_t len = strlen(str) + 1;
    char *copy = new char[len];    
    return copy;
}

char *strDupSize(const char *str, size_t &resultBufSize)
{
    if (NULL == str)
    {
        resultBufSize = 0;
        return NULL;
    }

    resultBufSize = strlen(str) + 1;
    char *copy = new char[resultBufSize];    
    return copy;
}
